/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import control.DBHandler;
import control.VareHandler;
import interfaces.GGInterface;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Jonas
 */
public class Main {

    public static DBHandler dh;
    public static VareHandler vh;

    /**
     * @param args the command line arguments
     * @throws java.rmi.RemoteException
     * @throws javax.naming.NamingException
     * @throws java.net.MalformedURLException
     */
    public static void main(String[] args) throws RemoteException, NamingException, MalformedURLException {
        try {
            System.out.print("Forbinder til databasen...");
            dh = new DBHandler();
            System.out.println("Done\n");

            vh = new VareHandler();

        } catch (SQLException ex) {
            System.out.println("sql fejl");
        } catch (ClassNotFoundException ex) {
            System.out.println("driver fejl");
        }
        System.out.print("Laver registret...");
        java.rmi.registry.LocateRegistry.createRegistry(1099);
        System.out.println("Done\n");

        GGInterface ggi = new GG();
        System.out.print("Tilknytter GG til registret...");
        Context nameContext = new InitialContext();
        nameContext.bind("rmi:gg", ggi);
        System.out.println("Done\n");

        System.out.print("Serveren done! Venter på klienten...");
    }
}
